class User < ActiveRecord::Base
  validates_presence_of :username,:password
  validates_uniqueness_of :username
  def self.login(username,password)
    find(:first,
         :conditions => ["username= ? and password= ?", username, password])
  end
  def try_to_login
    User.login(self.username, self.password)
  end  
    before_destroy :dont_destroy_developer
  def dont_destroy_developer
    raise "Can't destroy developer" if self.name == 'developer'
  end
end
